package com.wy.panda.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.wy.panda.common.sign.PandaSignConfig;
import com.wy.panda.common.sign.PandaSignValidator;

/**
 * 验签拦截器
 *
 * @author WangYuan
 * @since 2020年11月6日 下午12:45:00
 */
@Component
public class ValidateSignInterceptor extends HandlerInterceptorAdapter {
	
	private PandaSignValidator validator;
	
	{
		validator = new PandaSignValidator();
		
		PandaSignConfig.registerApp("654321", "5fFb9bD&801ca42be9@e24a4211f#8Y7g02");
	}
	
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		return validator.validate(request, response);
	}

}
